package adcp.views.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xkh.xkh.R;

import java.util.List;

import adcp.network.beans.GateDownLoad;


/**
 * Created by nimi on 2015/10/29.
 */
public class GateAdapter extends BaseAdapter {
    private List<GateDownLoad> gateDownLoads;

    private Context mContext;
    public GateAdapter(Context context, List<GateDownLoad> gateDownLoads) {
        this.mContext=context;
        this.gateDownLoads = gateDownLoads;
    }
    //返回已获得数据源总数量
    public int getCount() {
        // TODO Auto-generated method stub
        if(gateDownLoads != null)
            return gateDownLoads.size();
        else
            return 0;
    }

    @Override
    //告诉适配器取得目前容器中的数据对象
    public GateDownLoad getItem(int position) {
        // TODO Auto-generated method stub
        return  gateDownLoads == null ? null : gateDownLoads.get(position);//返回该位置对应的gate信息
    }

    @Override
    //告诉适配器取得目前容器中的数据ID
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    //取得当前欲显示的图像View
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        LayoutInflater _LayoutInflater=LayoutInflater.from(mContext);
        convertView=_LayoutInflater.inflate(R.layout.item_spinner, null);
        if(convertView!=null) {
            TextView _TextView1=(TextView)convertView.findViewById(R.id.item);
            _TextView1.setText(gateDownLoads.get(position).getGate_name());

        }
        return convertView;
    }
}
